﻿@model PagedList.IPagedList<dziennik_asp_mvc.Models.Entities.Users>
@using PagedList.Mvc;

<div class="panel panel-primary">
    <div class="panel-body" style="margin-bottom: 10px;">
        <div style="float:right; margin-bottom:10px;">
        @if (User.IsInRole("Administrator")) {
            <a class="btn btn-primary btn-small" href="/Users/Teachers/Create">
                <span class="glyphicon glyphicon-plus-sign icon-white" style="margin-right:5px;"></span>
                Dodaj wykładowcę
            </a>
        }
        </div>
        @using (Html.BeginForm("List", "Teachers", new { currentFilter = ViewBag.CurrentFilter }, FormMethod.Get, new { @class = "form-inline", role = "form" }))
        {
            <div class="col-lg-3">
                <input id="searchInput" name="searchString" type="text" autofocus="autofocus" class="form-control" />
            </div>
            <button id="sumbitSearch" type="submit" class="btn btn-primary">
                <span class="glyphicon glyphicon-search" style="margin-right: 5px;"></span>
                Szukaj
            </button>
        }
    </div>
</div>


<table class="table table-bordered table-striped table-condensed">
    <tr>
        <th scope="col" style="text-align: center !important;">
            @Html.ActionLink("Nazwa użytkownika", "List", new { sort = ViewBag.CurrentSort, column = "login", currentFilter = ViewBag.CurrentFilter })
        </th>
        <th scope="col" style="text-align: center !important;">
            @Html.ActionLink("Imię", "List", new { sort = ViewBag.CurrentSort, column = "firstName", currentFilter = ViewBag.CurrentFilter })
        </th>
        <th scope="col" style="text-align: center !important;">
            @Html.ActionLink("Nazwisko", "List", new { sort = ViewBag.CurrentSort, column = "lastName", currentFilter = ViewBag.CurrentFilter })
        </th>
        <th scope="col" style="text-align: center !important;">
            @Html.ActionLink("E-mail", "List", new { sort = ViewBag.CurrentSort, column = "email", currentFilter = ViewBag.CurrentFilter })
        </th>
        <th scope="col" style="text-align: center !important;">
            @Html.ActionLink("Status konta", "List", new { sort = ViewBag.CurrentSort, column = "status", currentFilter = ViewBag.CurrentFilter })
        </th>
        <th></th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td style="text-align: center; vertical-align: middle;">
                @Html.DisplayFor(modelItem => item.login)
            </td>
            <td style="text-align: center; vertical-align: middle;">
                @Html.DisplayFor(modelItem => item.first_name)
            </td>
            <td style="text-align: center; vertical-align: middle;">
                @Html.DisplayFor(modelItem => item.last_name)
            </td>
            <td style="text-align: center; vertical-align: middle;">
                @Html.DisplayFor(modelItem => item.email)
            </td>
            <td style="text-align: center; vertical-align: middle;">
                <span class="@(@item.status ? "glyphicon glyphicon-eye-open" : "glyphicon glyphicon-eye-close")"></span>
            </td>
            <td style="text-align: center; vertical-align: middle;">
                <a id="subjectsInGroupLink" class="btn btn-success btn-small" href="/Users/@{@item.id_user}/Profile/">
                    <span class="glyphicon glyphicon-list-alt icon-white" style="margin-right:5px;"></span>
                    Profil
                </a>
                <a id="subjectsInGroupLink" class="btn btn-success btn-small" href="/Users/Teachers/Subjects/@{@item.id_user}">
                    <span class="glyphicon glyphicon-list-alt icon-white" style="margin-right:5px;"></span>
                    Lista przedmiotów
                </a>
                @if (User.IsInRole("Administrator")) { 
                    <a id="teacherEditLink" class="btn btn-primary btn-small" href="/Users/Teachers/Edit/@{@item.id_user}">
                        <span class="glyphicon glyphicon-edit icon-white" style="margin-right:5px;"></span>
                        Edytuj
                    </a>
                    <a id="teacherDeleteLink" class="btn btn-danger btn-small" href="/Users/Teachers/Delete/@{@item.id_user}">
                        <span class="glyphicon glyphicon-remove-sign" style="margin-right:5px;"></span>
                        Usuń
                    </a>
                }
            </td>
        </tr>
    }

</table>
<div style="text-align:center">
    @Html.PagedListPager(Model, page => Url.Action("List", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }),
        new PagedListRenderOptions
        {
            DisplayLinkToFirstPage = PagedListDisplayMode.Always,
            DisplayLinkToLastPage = PagedListDisplayMode.Always,
            DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
            DisplayLinkToNextPage = PagedListDisplayMode.Always,
            DisplayLinkToIndividualPages = false
        })
</div>